#ifndef __INCLUDES_H__
#define __INCLUDES_H__ 

#include <MC9S12XS128.h> 
#include "OLED.h"

#define angle       PWMDTY01      //舵机
#define speed_go    PWMDTY23      //设置通道3的占空比  前进
#define speed_back  PWMDTY45      //        5          后退

#define TSL_CLK     PORTA_PA4     // CCD CLK
#define TSL_SI      PORTA_PA2     // CCD SI 

#define Red_stop1    PORTA_PA7     //红外后
#define Red_stop2    PORTA_PA5     //红外前
#define red_light   PORTA_PA3     //红灯
//#define green_light PORTA_PA3     //绿灯

#define key1        PORTB_PB1     //按键1          //高电平有效
#define key2        PORTB_PB3     //按键2
//#define key3        PORTE_PE3     //按键3
//#define key4        PORTE_PE2     //按键4

#define switch1     PORTB_PB4     //拨码1
#define switch2     PORTB_PB2     //拨码2
#define switch3     PORTB_PB0     //拨码3
#define switch4     PTT_PTT6      //拨码4




//初始化 
extern void Init_All(void);
extern void Delay_us(word n_us);
extern void Delay_ms(word n_ms);
extern void Delay_s(word n_s);
 

//CCD
extern unsigned int ReadATD(unsigned char Ch);
extern void Pixel_Get(void);
extern void Position_calculate(void);

extern void SendImageData(unsigned char * ImageData); 


//显示屏
extern void OLED_display(void);

//Flash
extern void DFlash_Init(void);
extern void DFlash_Write(word ADDR16);
extern word DFlash_Read (word destination);
extern void DFlash_Erase(word ADDR16);

extern void Read_Write_Flash(void);

//舵机

//速度
extern void speedget(void);
extern void car_control(void);

//蓝牙
extern void SCI_send(unsigned char data);
extern void send_int(int data);
extern void send_string(char *putchar);
extern void OutPut_Data(void);
extern void Buletooth(void);
 
//PID
extern void Steer_PD(float sp,float sd,int ch1);
extern void Motor_PID(int in1);

extern void value_change(void);

extern unsigned int abs(int a);         //取绝对值
extern unsigned int a_b(int a,int b);   //相减取绝对值  

//道路识别
extern void PathOperation(void);
extern void pathfilter(void);


#endif
